package com.tao.YanMoDesignPattern.composite.case2_parent;


/**
 * @Author Mi_Tao
 * @Date 2023/8/27
 * @Description
 * @Version 1.0
 **/
public class Client
 {

    public static void main(String[] args){
        // 定义多个Composite对象
        Component root = new Composite("服装");
        Component c1 =   new Composite("男装");
        Component c2 =   new Composite("女装");
        // 定义多个Leaf对象
        Component c11 = new Composite("衬衣");
        Component Leaf2 = new Leaf("夹克");
        Component Leaf3 = new Leaf("裙子");
        Component Leaf4 = new Leaf("套装");

        Component Leaf11 = new Leaf("秋季衬衣");

        // 组合成属性的对象结构
        root.addChild(c1);
        root.addChild(c2);
        c1.addChild(c11);
        c1.addChild(Leaf2);
        c2.addChild(Leaf3);
        c2.addChild(Leaf4);

        c11.addChild(Leaf11);
        // 操作Component 对象
        root.printStruct("");

        // 测试删除操作
        root.removeChild(c1);
        System.out.println("删除男装节点后整棵树=========");
        // 重新输出整棵树
        root.printStruct("");

    }
}
